/*
 * Copyright the original author or authors.
 * 
 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.mozilla.org/MPL/MPL-1.1.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.babeuf.form.errors 
{
	import net.babeuf.form.fields.AbstractField;
	
	/**
	 * FieldError is a value object for form errors 
	 * 
	 * @author damien pegoraro
	 * 
	 * @langversion 3.0
	 * @playerversion Flash 10
	 */
	public class FieldError
	{
		/**
		 * The form field instance
		 * 
		 * @langversion 3.0
		 * @playerversion Flash 10
		 */
		public var field : AbstractField ; 
		
		/**
		 * The error code registered in the messager
		 * 
		 * @langversion 3.0
		 * @playerversion Flash 10
		 */		
		public var code : String ; 
		
		/**
		 * The full error message
		 * 
		 * @langversion 3.0
		 * @playerversion Flash 10
		 */
		public var message : String ; 
				
		/**
		 * Creates a new instance
		 * 
		 * @param	field The related form <code>AbstractField</code> instance
		 * @param	code The error code
		 * @param	message The full error message
		 * 
		 * @langversion 3.0
		 * @playerversion Flash 10
		 */
		public function FieldError( field : AbstractField, code : String, message : String = "" ) 
		{
			this.field = field ;
			this.code = code ; 
			this.message = message;  
		}
		
		/**
		 * Returns the <code>String</code> representation of the FieldError		 
		 * @return the <code>String</code> representation
		 * 
		 * @langversion 3.0
		 * @playerversion Flash 10
		 */
		public function toString() : String
		{
			return "ERROR : " + code + " -> " + message + "\n" ; 
		}
		
	}

}